package com.example.demo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author victor
 * @CreateTime 2021/09/09
 **/
@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
    /**
     * 在这里添加自己定义的拦截器
     * @param registry
     */

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TestInterceptor())
                // 只拦截test路径
                .addPathPatterns("/house/**")
                // 不拦截pass路径
                .excludePathPatterns("/house/v1/users/login/**")
                .excludePathPatterns(("/house/v1/users/**"));
    }
}
